/*
 * OpenParts
 * A dynamic-loading components framework for GWT
 * Copyright (C) 2011 Christophe Bouthier  [chris{AT}binary-gastronome{DOT}fr]
 *
 * This work is partially based on work I have done at INRIA (http://www.inria.fr) 
 * in the context of the Qualipso European Project (http://qualipso.org/),
 * The work done at INRIA is Copyright (C) 2006-2011 INRIA
 *
 * This work is distributed under the LGPL version 3
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. See the GNU
 * Lesser General Public License in LGPL.txt for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package fr.openparts.opshowcase.showcase.client.presenter;


import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;

import fr.openparts.OpenParts.client.OPBinder;
import fr.openparts.OpenParts.client.OPParams;
import fr.openparts.OpenParts.client.OPShell;
import fr.openparts.OpenParts.client.OPSlot;
import fr.openparts.OpenParts.client.OPSlotProxy;
import fr.openparts.OpenParts.client.annotations.OPServiceName;
import fr.openparts.OpenParts.client.annotations.OPViewFactory;
import fr.openparts.opshowcase.showcase.client.view.ShowcaseView;

/**
 * Main presenter for OpenParts Showcase
 * 
 * @author Christophe Bouthier [chris{AT}binary-gastronome{DOT}fr]
 * @creation.date 23 January 2011
 */
@OPServiceName("showcase")
public class ShowcasePresenter implements EntryPoint {

    public interface ShowcasePresenterBinder extends OPBinder<ShowcasePresenter> {}
    public final static ShowcasePresenterBinder binder = GWT.create(ShowcasePresenterBinder.class);

    protected ShowcaseView view;
    
    /**
     * Entry point, method called when the module is loaded.
     * 
     * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
     */
    @Override
    public void onModuleLoad() {
        binder.bindPart(this);
        view = new ShowcaseView(this);
        binder.notifyLoadingCompleted();
    }

    /**
     * Returns the main view for the showcase
     * 
     * @param params
     *            not used here
     * @return the main view of the showcase
     */
    @OPViewFactory(resourceName = "showcase", actionName = OPShell.ACTION_ROOT)
    public Widget getMainView(final OPParams params, final OPSlotProxy proxy) {
        return view;
    }
    
    /**
     * Display the showcase of displaying view
     */
     public void displayDisplayView() {
         final OPSlot slot = OPShell.getSlot("displaylevel1", "displaylevel1", OPShell.ACTION_DISPLAY);
         view.setContent(slot);
         OPShell.displayView("displaylevel1", "displaylevel1", OPShell.ACTION_DISPLAY, slot);
     }
     
     /**
      * Display the showcase of event dispatching
      */
      public void displayEventDispatching() {
          final OPSlot slot = OPShell.getSlot("eventmodule", "eventmodule", OPShell.ACTION_DISPLAY);
          view.setContent(slot);
          OPShell.displayView("eventmodule", "eventmodule", OPShell.ACTION_DISPLAY, slot);
      }
    
    /**
     * Display the showcase of message dispatching
     */
     public void displayMessageDispatching() {
         final OPSlot slot = OPShell.getSlot("messagecontainer", "messagecontainer", OPShell.ACTION_DISPLAY);
         view.setContent(slot);
         OPShell.displayView("messagecontainer", "messagecontainer", OPShell.ACTION_DISPLAY, slot);
     }
     
     /**
      * Display the showcase of errors reporting
      */
      public void displayErrorsReporting() {
          final OPSlot slot = OPShell.getSlot("errorsreporting", "errorsreporting", OPShell.ACTION_DISPLAY);
          view.setContent(slot);
          OPShell.displayView("errorsreporting", "errorsreporting", OPShell.ACTION_DISPLAY, slot);
      }
      
      /**
       * Display the showcase of scheduler
       */
       public void displaySchedulerModule() {
           final OPSlot slot = OPShell.getSlot("schedulermodule", "schedulermodule", OPShell.ACTION_DISPLAY);
           view.setContent(slot);
           OPShell.displayView("schedulermodule", "schedulermodule", OPShell.ACTION_DISPLAY, slot);
       }
       
       /**
        * Display the showcase of proxy commands
        */
        public void displayWidgetContainer() {
            final OPSlot slot = OPShell.getSlot("widgetcontainer", "widgetcontainer", OPShell.ACTION_DISPLAY);
            view.setContent(slot);
            OPShell.displayView("widgetcontainer", "widgetcontainer", OPShell.ACTION_DISPLAY, slot);
        }
}
